Move orientable style classes into GtkWidget
authorEmmanuele Bassi <ebassi@gnome.org>
Thu, 23 Apr 2020 16:48:29 +0000 (17:48 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Fri, 5 Jun 2020 19:35:09 +0000 (20:35 +0100)
It feels slightly wrong to have GtkOrientable operate on widgets, but at
least what happens when an orientable widget changes orientation should
be part of GtkWidget.

This will allow to add more state changes without accessing widget state
from the outside of gtkwidget.c.

20 files changed:
docs/reference/gtk/meson.build
gtk/gtkbox.c
gtk/gtkboxlayout.c
gtk/gtkcellview.c
gtk/gtkcenterbox.c
gtk/gtkflowbox.c
gtk/gtkgrid.c
gtk/gtkgridlayout.c
gtk/gtklevelbar.c
gtk/gtklistbase.c
gtk/gtkorientable.c
gtk/gtkorientableprivate.h [deleted file]
gtk/gtkpaned.c
gtk/gtkprogressbar.c
gtk/gtkrange.c
gtk/gtkscrollbar.c
gtk/gtkseparator.c
gtk/gtkspinbutton.c
gtk/gtkwidget.c
gtk/gtkwidgetprivate.h

index 2deb4a3d0090bb4a2d5ba0a3097cae20075e0ef8..45fc4e5c93d6d57bdf31ba54b6336687a3e17b83 100644 (file)
@@ -152,7 +152,6 @@ private_headers = [
   'gtkmountoperationprivate.h',
   'gtknativedialogprivate.h',
   'gtknomediafileprivate.h',
-  'gtkorientableprivate.h',
   'gtkplacessidebarprivate.h',
   'gtkplacesviewprivate.h',
   'gtkplacesviewrowprivate.h',
index e1539ff4ce4e45425dd8108a92ed36566778ad75..d4c296e7df801fa460be840da0ab12fd3f4a7366 100644 (file)
@@ -61,7 +61,6 @@
 #include "gtkcsspositionvalueprivate.h"
 #include "gtkintl.h"
 #include "gtkorientable.h"
-#include "gtkorientableprivate.h"
 #include "gtkprivate.h"
 #include "gtktypebuiltins.h"
 #include "gtksizerequest.h"
@@ -120,7 +119,7 @@ gtk_box_set_property (GObject      *object,
             priv->orientation = orientation;
             gtk_orientable_set_orientation (GTK_ORIENTABLE (box_layout),
                                             priv->orientation);
-            _gtk_orientable_set_style_classes (GTK_ORIENTABLE (box));
+            gtk_widget_update_orientation (GTK_WIDGET (box), priv->orientation);
             g_object_notify (object, "orientation");
           }
       }
@@ -288,7 +287,7 @@ gtk_box_init (GtkBox *box)
   GtkBoxPrivate *priv = gtk_box_get_instance_private (box);
 
   priv->orientation = GTK_ORIENTATION_HORIZONTAL;
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (box));
+  gtk_widget_update_orientation (GTK_WIDGET (box), priv->orientation);
 }
 
 static GtkBuildableIface *parent_buildable_iface;
index 098375973b2ccc635bdd5e1f33cbb1d7595c59c4..d06f5983a8d0099d7fc81add239ec60731546700 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "gtkcsspositionvalueprivate.h"
 #include "gtkintl.h"
-#include "gtkorientableprivate.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtksizerequest.h"
 #include "gtkstylecontextprivate.h"
@@ -89,7 +89,7 @@ gtk_box_layout_set_orientation (GtkBoxLayout   *self,
 
   widget = gtk_layout_manager_get_widget (layout_manager);
   if (widget != NULL && GTK_IS_ORIENTABLE (widget))
-    _gtk_orientable_set_style_classes (GTK_ORIENTABLE (widget));
+    gtk_widget_update_orientation (widget, self->orientation);
 
   gtk_layout_manager_layout_changed (layout_manager);
 
index 12132c29440901ebe6b31a9a2485cc1a37508f7e..a7b5a9c3a95e271fc57e28931d8f754149bc795b 100644 (file)
  */
 
 #include "config.h"
-#include <string.h>
+
 #include "gtkcellview.h"
+
+#include "gtkbuildable.h"
 #include "gtkcelllayout.h"
 #include "gtkcellareabox.h"
-#include "gtkintl.h"
-#include "gtkcellrenderertext.h"
 #include "gtkcellrendererpixbuf.h"
+#include "gtkcellrenderertext.h"
+#include "gtkintl.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
-#include "gtkorientableprivate.h"
 #include "gtkwidgetprivate.h"
+
 #include <gobject/gmarshal.h>
-#include "gtkbuildable.h"
 
+#include <string.h>
 
 /**
  * SECTION:gtkcellview
@@ -385,7 +388,7 @@ gtk_cell_view_set_property (GObject      *object,
           priv->orientation = g_value_get_enum (value);
           if (priv->context)
             gtk_cell_area_context_reset (priv->context);
-          _gtk_orientable_set_style_classes (GTK_ORIENTABLE (object));
+          gtk_widget_update_orientation (GTK_WIDGET (object), priv->orientation);
           g_object_notify_by_pspec (object, pspec);
         }
       break;
index 8bd0a7fda07d4390e4c4d4ce3a6b343f661b773b..e3536be6d92edb1ca4aebbb17cf193ee703829df 100644 (file)
@@ -58,7 +58,6 @@
 #include "gtkcssnodeprivate.h"
 #include "gtkwidgetprivate.h"
 #include "gtkorientable.h"
-#include "gtkorientableprivate.h"
 #include "gtkbuildable.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
@@ -140,7 +139,7 @@ gtk_center_box_set_property (GObject      *object,
         if (current != orientation)
           {
             gtk_center_layout_set_orientation (GTK_CENTER_LAYOUT (layout), orientation);
-            _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
+            gtk_widget_update_orientation (GTK_WIDGET (self), orientation);
             gtk_widget_queue_resize (GTK_WIDGET (self));
             g_object_notify (object, "orientation");
           }
index 033b227e45d449b9cf90ae7cbecba30dd0755371..f9743e04e646dd8c8464658a8badde42f467eecb 100644 (file)
@@ -75,7 +75,6 @@
 
 #include <config.h>
 
-#include "gtkflowbox.h"
 #include "gtkflowboxprivate.h"
 
 #include "gtkadjustment.h"
 #include "gtkbuildable.h"
 #include "gtkcsscolorvalueprivate.h"
 #include "gtkcssnodeprivate.h"
-#include "gtkgesturedrag.h"
+#include "gtkeventcontrollerkey.h"
 #include "gtkgestureclick.h"
+#include "gtkgesturedrag.h"
 #include "gtkintl.h"
 #include "gtkmain.h"
 #include "gtkmarshalers.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
-#include "gtkorientableprivate.h"
 #include "gtkrender.h"
 #include "gtksizerequest.h"
 #include "gtksnapshot.h"
@@ -97,7 +97,6 @@
 #include "gtktypebuiltins.h"
 #include "gtkviewport.h"
 #include "gtkwidgetprivate.h"
-#include "gtkeventcontrollerkey.h"
 
 #include "a11y/gtkflowboxaccessibleprivate.h"
 #include "a11y/gtkflowboxchildaccessible.h"
@@ -3441,14 +3440,20 @@ gtk_flow_box_set_property (GObject      *object,
   switch (prop_id)
     {
     case PROP_ORIENTATION:
-      if (priv->orientation != g_value_get_enum (value))
-        {
-          priv->orientation = g_value_get_enum (value);
-          _gtk_orientable_set_style_classes (GTK_ORIENTABLE (box));
-          /* Re-box the children in the new orientation */
-          gtk_widget_queue_resize (GTK_WIDGET (box));
-          g_object_notify_by_pspec (object, pspec);
-        }
+      {
+        GtkOrientation orientation = g_value_get_enum (value);
+
+        if (priv->orientation != orientation)
+          {
+            priv->orientation = orientation;
+
+            gtk_widget_update_orientation (GTK_WIDGET (box), priv->orientation);
+
+            /* Re-box the children in the new orientation */
+            gtk_widget_queue_resize (GTK_WIDGET (box));
+            g_object_notify_by_pspec (object, pspec);
+          }
+      }
       break;
     case PROP_HOMOGENEOUS:
       gtk_flow_box_set_homogeneous (box, g_value_get_boolean (value));
@@ -3890,7 +3895,7 @@ gtk_flow_box_init (GtkFlowBox *box)
   priv->row_spacing = 0;
   priv->activate_on_single_click = TRUE;
 
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (box));
+  gtk_widget_update_orientation (GTK_WIDGET (box), priv->orientation);
 
   priv->children = g_sequence_new (NULL);
 
index 2a1fec34917b53fc8fdbe5b129b1b047853519ff..fcee1db68564e762d5472bb896af272597d109fb 100644 (file)
@@ -25,8 +25,8 @@
 #include "gtkbuildable.h"
 #include "gtkcsspositionvalueprivate.h"
 #include "gtkgridlayout.h"
-#include "gtkorientableprivate.h"
 #include "gtkintl.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtksizerequest.h"
 #include "gtkstylecontextprivate.h"
@@ -135,7 +135,8 @@ gtk_grid_set_orientation (GtkGrid        *grid,
   if (priv->orientation != orientation)
     {
       priv->orientation = orientation;
-      _gtk_orientable_set_style_classes (GTK_ORIENTABLE (grid));
+
+      gtk_widget_update_orientation (GTK_WIDGET (grid), priv->orientation);
 
       g_object_notify (G_OBJECT (grid), "orientation");
     }
@@ -435,7 +436,7 @@ gtk_grid_init (GtkGrid *grid)
   priv->layout_manager = gtk_widget_get_layout_manager (GTK_WIDGET (grid));
 
   priv->orientation = GTK_ORIENTATION_HORIZONTAL;
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (grid));
+  gtk_widget_update_orientation (GTK_WIDGET (grid), priv->orientation);
 }
 
 /**
index b77169e76f8455f6a3afd432b73293bcb3b55c12..08fce7fbdea854fc19ca6dfc2340a2ebf4284614 100644 (file)
@@ -48,7 +48,7 @@
 #include "gtkdebug.h"
 #include "gtkintl.h"
 #include "gtklayoutchild.h"
-#include "gtkorientableprivate.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtksizerequest.h"
 #include "gtkstylecontextprivate.h"
index caafb489f4c25d4938176fee136dbcbd327cc4a8..d95dba07824d4855ba0ecd51daa3f1660aacd444 100644 (file)
 #include "gtkbinlayout.h"
 #include "gtkbuildable.h"
 #include "gtkbuilderprivate.h"
+#include "gtkcssstylepropertyprivate.h"
+#include "gtkcssnodeprivate.h"
+#include "gtkgizmoprivate.h"
 #include "gtkintl.h"
-#include "gtkorientableprivate.h"
 #include "gtklevelbar.h"
 #include "gtkmarshalers.h"
-#include "gtkstylecontext.h"
+#include "gtkorientable.h"
+#include "gtkstylecontextprivate.h"
 #include "gtktypebuiltins.h"
-#include "gtkwidget.h"
 #include "gtkwidgetprivate.h"
-#include "gtkstylecontextprivate.h"
-#include "gtkcssstylepropertyprivate.h"
-#include "gtkcssnodeprivate.h"
-#include "gtkgizmoprivate.h"
 
 #include <math.h>
 #include <stdlib.h>
@@ -796,7 +794,7 @@ gtk_level_bar_set_orientation (GtkLevelBar    *self,
   if (self->orientation != orientation)
     {
       self->orientation = orientation;
-      _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
+      gtk_widget_update_orientation (GTK_WIDGET (self), self->orientation);
       gtk_widget_queue_resize (GTK_WIDGET (self));
       g_object_notify (G_OBJECT (self), "orientation");
     }
@@ -1012,7 +1010,7 @@ gtk_level_bar_init (GtkLevelBar *self)
 
   /* set initial orientation and style classes */
   self->orientation = GTK_ORIENTATION_HORIZONTAL;
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
+  gtk_widget_update_orientation (GTK_WIDGET (self), self->orientation);
 
   self->inverted = FALSE;
 
index 373ba704e323636af2ba80d309481abce507c9a6..50cdcb84fa6f70c951b1bb8b845f5572df17697a 100644 (file)
 #include "gtklistbaseprivate.h"
 
 #include "gtkadjustment.h"
+#include "gtkgesturedrag.h"
+#include "gtkgizmoprivate.h"
 #include "gtkintl.h"
 #include "gtklistitemwidgetprivate.h"
-#include "gtkorientableprivate.h"
+#include "gtkmultiselection.h"
+#include "gtkorientable.h"
 #include "gtkscrollable.h"
+#include "gtkset.h"
 #include "gtksingleselection.h"
+#include "gtksnapshot.h"
+#include "gtkstylecontextprivate.h"
 #include "gtktypebuiltins.h"
-#include "gtkgesturedrag.h"
 #include "gtkwidgetprivate.h"
-#include "gtkstylecontextprivate.h"
-#include "gtksnapshot.h"
-#include "gtkmultiselection.h"
-#include "gtkgizmoprivate.h"
-#include "gtkset.h"
 
 typedef struct _RubberbandData RubberbandData;
 
@@ -708,7 +708,7 @@ gtk_list_base_set_property (GObject      *object,
         if (priv->orientation != orientation)
           {
             priv->orientation = orientation;
-            _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
+            gtk_widget_update_orientation (GTK_WIDGET (self), priv->orientation);
             gtk_widget_queue_resize (GTK_WIDGET (self));
             g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ORIENTATION]);
           }
index 4987a6c76c9af5b468ce12fe62242c0feb348b94..8bfb629285d2590cbf93f8d8fadf656a252671ff 100644 (file)
 
 #include "config.h"
 
-#include "gtkorientableprivate.h"
+#include "gtkorientable.h"
 
 #include "gtkprivate.h"
+#include "gtkwidgetprivate.h"
 #include "gtkstylecontext.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
@@ -81,7 +82,7 @@ gtk_orientable_set_orientation (GtkOrientable  *orientable,
                 NULL);
 
   if (GTK_IS_WIDGET (orientable))
-    _gtk_orientable_set_style_classes (orientable);
+    gtk_widget_update_orientation (GTK_WIDGET (orientable), orientation);
 }
 
 /**
@@ -106,25 +107,3 @@ gtk_orientable_get_orientation (GtkOrientable *orientable)
 
   return orientation;
 }
-
-void
-_gtk_orientable_set_style_classes (GtkOrientable *orientable)
-{
-  GtkOrientation orientation;
-
-  g_return_if_fail (GTK_IS_ORIENTABLE (orientable));
-  g_return_if_fail (GTK_IS_WIDGET (orientable));
-
-  orientation = gtk_orientable_get_orientation (orientable);
-
-  if (orientation == GTK_ORIENTATION_HORIZONTAL)
-    {
-      gtk_widget_add_css_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_HORIZONTAL);
-      gtk_widget_remove_css_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_VERTICAL);
-    }
-  else
-    {
-      gtk_widget_add_css_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_VERTICAL);
-      gtk_widget_remove_css_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_HORIZONTAL);
-    }
-}
diff --git a/gtk/gtkorientableprivate.h b/gtk/gtkorientableprivate.h
deleted file mode 100644 (file)
index 00eaaa9..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2011 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GTK_ORIENTABLE_PRIVATE_H__
-#define __GTK_ORIENTABLE_PRIVATE_H__
-
-#include "gtkorientable.h"
-
-G_BEGIN_DECLS
-
-void _gtk_orientable_set_style_classes (GtkOrientable *orientable);
-
-G_END_DECLS
-
-#endif /* __GTK_ORIENTABLE_H__ */
index 6c233c4b62eceed9c7b171b2c9ad54b787afc9a2..9a0313c5afa1414e51cdcb64951a547afb073402 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "gtkpaned.h"
 
+#include "gtkcssboxesprivate.h"
 #include "gtkcssnodeprivate.h"
 #include "gtkcssstylepropertyprivate.h"
 #include "gtkeventcontrollermotion.h"
@@ -34,7 +35,7 @@
 #include "gtkgizmoprivate.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
-#include "gtkorientableprivate.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtkrendericonprivate.h"
 #include "gtkstylecontextprivate.h"
@@ -389,6 +390,30 @@ gtk_paned_get_request_mode (GtkWidget *widget)
         GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
 }
 
+static void
+gtk_paned_set_orientation (GtkPaned       *self,
+                           GtkOrientation  orientation)
+{
+  if (self->orientation != orientation)
+    {
+      static const char *cursor_name[2] = {
+        "col-resize",
+        "row-resize",
+      };
+
+      self->orientation = orientation;
+
+      gtk_widget_update_orientation (GTK_WIDGET (self), self->orientation);
+      gtk_widget_set_cursor_from_name (self->handle_widget,
+                                       cursor_name[orientation]);
+      gtk_gesture_pan_set_orientation (GTK_GESTURE_PAN (self->pan_gesture),
+                                       orientation);
+
+      gtk_widget_queue_resize (GTK_WIDGET (self));
+      g_object_notify (G_OBJECT (self), "orientation");
+    }
+}
+
 static void
 gtk_paned_class_init (GtkPanedClass *class)
 {
@@ -919,29 +944,7 @@ gtk_paned_set_property (GObject        *object,
   switch (prop_id)
     {
     case PROP_ORIENTATION:
-      if (paned->orientation != g_value_get_enum (value))
-        {
-          paned->orientation = g_value_get_enum (value);
-          _gtk_orientable_set_style_classes (GTK_ORIENTABLE (paned));
-
-          if (paned->orientation == GTK_ORIENTATION_HORIZONTAL)
-            {
-              gtk_gesture_pan_set_orientation (GTK_GESTURE_PAN (paned->pan_gesture),
-                                               GTK_ORIENTATION_HORIZONTAL);
-              gtk_widget_set_cursor_from_name (paned->handle_widget,
-                                               "col-resize");
-            }
-          else
-            {
-              gtk_gesture_pan_set_orientation (GTK_GESTURE_PAN (paned->pan_gesture),
-                                               GTK_ORIENTATION_VERTICAL);
-              gtk_widget_set_cursor_from_name (paned->handle_widget,
-                                               "row-resize");
-            }
-
-          gtk_widget_queue_resize (GTK_WIDGET (paned));
-          g_object_notify_by_pspec (object, pspec);
-        }
+      gtk_paned_set_orientation (paned, g_value_get_enum (value));
       break;
     case PROP_POSITION:
       gtk_paned_set_position (paned, g_value_get_int (value));
@@ -1450,7 +1453,7 @@ gtk_paned_init (GtkPaned *paned)
   paned->shrink_start_child = TRUE;
   paned->shrink_end_child = TRUE;
 
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (paned));
+  gtk_widget_update_orientation (GTK_WIDGET (paned), paned->orientation);
 
   /* Touch gesture */
   gesture = gtk_gesture_pan_new (GTK_ORIENTATION_HORIZONTAL);
index 58164c4e7e28b23aac260d9b76b25138ba2d09f4..53104999aaa98fb431f7f823e802202f83323f79 100644 (file)
 
 #include "gtkprogressbar.h"
 
+#include "gtkboxlayout.h"
 #include "gtkcssnodeprivate.h"
 #include "gtkcssnumbervalueprivate.h"
 #include "gtkcssstylepropertyprivate.h"
 #include "gtkgizmoprivate.h"
 #include "gtkintl.h"
 #include "gtklabel.h"
-#include "gtkorientableprivate.h"
+#include "gtkorientable.h"
 #include "gtkprogresstrackerprivate.h"
 #include "gtkprivate.h"
 #include "gtkstylecontextprivate.h"
 #include "gtkwidgetprivate.h"
-#include "gtkboxlayout.h"
 
 #include "a11y/gtkprogressbaraccessible.h"
 
@@ -457,7 +457,7 @@ gtk_progress_bar_init (GtkProgressBar *pbar)
   /* horizontal is default */
   pbar->orientation = GTK_ORIENTATION_VERTICAL; /* Just to force an update... */
   gtk_progress_bar_set_orientation (pbar, GTK_ORIENTATION_HORIZONTAL);
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (pbar));
+  gtk_widget_update_orientation (GTK_WIDGET (pbar), pbar->orientation);
 }
 
 static void
@@ -922,7 +922,7 @@ gtk_progress_bar_set_orientation (GtkProgressBar *pbar,
       gtk_widget_set_valign (pbar->trough_widget, GTK_ALIGN_FILL);
     }
 
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (pbar));
+  gtk_widget_update_orientation (GTK_WIDGET (pbar), pbar->orientation);
   update_node_classes (pbar);
 
   layout = GTK_BOX_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (pbar)));
index bc765d1f6749eb5c59c7f8f566805c78a094f9a5..916b63e2fc2619df77d901762a25cf4664ce4ea0 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "gtkadjustmentprivate.h"
 #include "gtkcolorscaleprivate.h"
+#include "gtkeventcontrollerkey.h"
 #include "gtkeventcontrollerscroll.h"
 #include "gtkgesturedrag.h"
 #include "gtkgesturelongpressprivate.h"
 #include "gtkgizmoprivate.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
-#include "gtkorientableprivate.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtkscale.h"
 #include "gtktypebuiltins.h"
-#include "gtkeventcontrollerkey.h"
+#include "gtkwidgetprivate.h"
 
 #include "a11y/gtkrangeaccessible.h"
 
@@ -458,7 +459,7 @@ gtk_range_set_property (GObject      *object,
       if (priv->orientation != g_value_get_enum (value))
         {
           priv->orientation = g_value_get_enum (value);
-          _gtk_orientable_set_style_classes (GTK_ORIENTABLE (range));
+          gtk_widget_update_orientation (GTK_WIDGET (range), priv->orientation);
           gtk_widget_queue_resize (GTK_WIDGET (range));
           g_object_notify_by_pspec (object, pspec);
         }
@@ -542,7 +543,7 @@ gtk_range_init (GtkRange *range)
   priv->fill_level = G_MAXDOUBLE;
   priv->timer = NULL;
 
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (range));
+  gtk_widget_update_orientation (GTK_WIDGET (range), priv->orientation);
 
   priv->trough_widget = gtk_gizmo_new ("trough",
                                        gtk_range_measure_trough,
index ab23a53095f0b265a81ce06c729e31c93bcc11df..7e9bdaae80527d404e441f88484612f2aeba6007 100644 (file)
@@ -31,7 +31,6 @@
 #include "gtkadjustment.h"
 #include "gtkintl.h"
 #include "gtkorientable.h"
-#include "gtkorientableprivate.h"
 #include "gtkprivate.h"
 #include "gtkwidgetprivate.h"
 #include "gtkboxlayout.h"
@@ -162,8 +161,7 @@ gtk_scrollbar_set_property (GObject      *object,
             gtk_orientable_set_orientation (GTK_ORIENTABLE (layout), orientation);
             gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->range), orientation);
             priv->orientation = orientation;
-            _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
-
+            gtk_widget_update_orientation (GTK_WIDGET (self), priv->orientation);
             gtk_widget_queue_resize (GTK_WIDGET (self));
             g_object_notify_by_pspec (object, pspec);
           }
@@ -223,8 +221,7 @@ gtk_scrollbar_init (GtkScrollbar *self)
   gtk_widget_set_hexpand (priv->range, TRUE);
   gtk_widget_set_vexpand (priv->range, TRUE);
   gtk_widget_set_parent (priv->range, GTK_WIDGET (self));
-
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
+  gtk_widget_update_orientation (GTK_WIDGET (self), priv->orientation);
 }
 
 /**
index 59cc5050a012c31acc81f04d30be8aa55e6319b1..4c2f23adb0056445985cbca0da792625a7d6104f 100644 (file)
@@ -26,8 +26,8 @@
 
 #include "gtkseparator.h"
 
-#include "gtkorientableprivate.h"
 #include "gtkintl.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtkwidgetprivate.h"
 
@@ -85,7 +85,8 @@ gtk_separator_set_property (GObject      *object,
       if (separator->orientation != g_value_get_enum (value))
         {
           separator->orientation = g_value_get_enum (value);
-          _gtk_orientable_set_style_classes (GTK_ORIENTABLE (object));
+          gtk_widget_update_orientation (GTK_WIDGET (object),
+                                         separator->orientation);
           gtk_widget_queue_resize (GTK_WIDGET (object));
           g_object_notify_by_pspec (object, pspec);
         }
@@ -120,7 +121,8 @@ gtk_separator_init (GtkSeparator *separator)
 {
   separator->orientation = GTK_ORIENTATION_HORIZONTAL;
 
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (separator));
+  gtk_widget_update_orientation (GTK_WIDGET (separator),
+                                 separator->orientation);
 }
 
 static void
index b159d341e5892087717a93ebfdbeef2707bbb985..5a80cbbe2d041072a876402cac09bb67ddf6f1fe 100644 (file)
@@ -47,7 +47,6 @@
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
 #include "gtkorientable.h"
-#include "gtkorientableprivate.h"
 #include "gtkprivate.h"
 #include "gtksettings.h"
 #include "gtkstylecontextprivate.h"
@@ -922,7 +921,8 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
 
   spin_button->orientation = GTK_ORIENTATION_HORIZONTAL;
 
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (spin_button));
+  gtk_widget_update_orientation (GTK_WIDGET (spin_button),
+                                 spin_button->orientation);
 
   spin_button->entry = gtk_text_new ();
   gtk_editable_init_delegate (GTK_EDITABLE (spin_button));
@@ -1089,7 +1089,7 @@ gtk_spin_button_set_orientation (GtkSpinButton  *spin,
     return;
 
   spin->orientation = orientation;
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (spin));
+  gtk_widget_update_orientation (GTK_WIDGET (spin), spin->orientation);
 
   /* change alignment if it's the default */
   if (spin->orientation == GTK_ORIENTATION_VERTICAL &&
index de02f2b3ae252f0fd4e798b064571e797d41c285..a56c55d06d9ed256eb00780c059893df81d6346d 100644 (file)
@@ -31,6 +31,7 @@
 #include "gtkapplicationprivate.h"
 #include "gtkbuildable.h"
 #include "gtkbuilderprivate.h"
+#include "gtkconstraint.h"
 #include "gtkcssboxesprivate.h"
 #include "gtkcssfiltervalueprivate.h"
 #include "gtkcsstransformvalueprivate.h"
 #include "gtklayoutmanagerprivate.h"
 #include "gtkmain.h"
 #include "gtkmarshalers.h"
+#include "gtknativeprivate.h"
 #include "gtkpopover.h"
 #include "gtkprivate.h"
 #include "gtkrenderbackgroundprivate.h"
 #include "gtkrenderborderprivate.h"
 #include "gtkrootprivate.h"
-#include "gtknativeprivate.h"
 #include "gtkscrollable.h"
 #include "gtksettingsprivate.h"
 #include "gtkshortcut.h"
@@ -71,8 +72,6 @@
 #include "gtkwidgetpaintableprivate.h"
 #include "gtkwindowgroup.h"
 #include "gtkwindowprivate.h"
-#include "gtknativeprivate.h"
-#include "gtkconstraint.h"
 
 #include "a11y/gtkwidgetaccessibleprivate.h"
 #include "inspector/window.h"
@@ -12775,3 +12774,29 @@ gtk_widget_set_css_classes (GtkWidget   *widget,
   gtk_css_node_set_classes (priv->cssnode, classes);
   g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CSS_CLASSES]);
 }
+
+/*< private >
+ * gtk_widget_update_orientation:
+ * @widget: a #GtkWidget implementing #GtkOrientable
+ * @orientation: the orientation
+ *
+ * Update the internal state associated to the given @orientation of a
+ * #GtkWidget.
+ */
+void
+gtk_widget_update_orientation (GtkWidget      *widget,
+                               GtkOrientation  orientation)
+{
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
+    {
+      gtk_widget_add_css_class (widget, GTK_STYLE_CLASS_HORIZONTAL);
+      gtk_widget_remove_css_class (widget, GTK_STYLE_CLASS_VERTICAL);
+    }
+  else
+    {
+      gtk_widget_add_css_class (widget, GTK_STYLE_CLASS_VERTICAL);
+      gtk_widget_remove_css_class (widget, GTK_STYLE_CLASS_HORIZONTAL);
+    }
+}
index 8e5517ae7f6b1e8fd2c28ba42a6deb04ea5f2e6c..e7688a65cdb3466e05cee50d4637701eccaed9bb 100644 (file)
@@ -369,6 +369,9 @@ gboolean gtk_widget_grab_focus_self  (GtkWidget        *widget);
 gboolean gtk_widget_focus_self       (GtkWidget        *widget,
                                       GtkDirectionType  direction);
 
+void    gtk_widget_update_orientation   (GtkWidget      *widget,
+                                         GtkOrientation  orientation);
+
 /* inline getters */
 
 static inline GtkWidget *